package 多线程初阶.线程的创建方式;

import static java.lang.Thread.sleep;

//匿名内部类实现
public class Demo3 {
    public static void main(String[] args) {
        Thread thread=new Thread(){
            @Override
            public void run() {
                while (true){
                    System.out.println("thread is run");
                    try {
                        sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        thread.start();
        while (true){
            System.out.println("main is run");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
